package framework.ai;

import java.awt.Component;
import java.io.File;

import nl.hanze.t23i.gamemodule.extern.*;
import framework.utils.GameModuleLoader;

/**
 * 
 * @author Henderikus Harms
 *
 */

public class Ai{
	private GameModuleLoader loader;
	private AbstractBoardGameModule currentGame; 
	private String playerOne, playerTwo;
	
	public Ai(String gameTypeName, String playerOne, String playerTwo){
		// get gameloader??
		this.loader = new GameModuleLoader();
		//load game module
		this.currentGame = (AbstractBoardGameModule) this.loader.loadGameModule(gameTypeName, playerOne, playerTwo);
		//setPlayers
		this.playerOne = playerOne;
		this.playerTwo = playerTwo;
	}
	
	/**
	 * This method determines with minimax the best
	 * possible move and returns it
	 * @return
	 */
	public BestMove chooseMove(){
		String opp = this.getOpponent();
		int value = currentGame.PLAYER_LOSS;
		int bestRow = 0;
		int simpleEval = 0;
		int bestColumn = 0;
		BestMove reply;
		
		for(int heigth = 0; heigth < currentGame.getHeigth(); heigth++){
			for(int width = 0; width < currentGame.getWidth(); width++){
				if(currentGame.isValidMove(width, heigth)){
					
				}
			}
		}
		
		return new BestMove(5);
	}
	
	/**
	 * return opponent of current player
	 * @return String opponent
 	 */
	private String getOpponent(){
		if(currentGame.getPlayerToMove().equals(playerOne)){
			return playerTwo;
		}else{
			return playerOne;
		}
	}
	
}
